<?php

class Welcome extends Controller {

	function Welcome()
	{
		parent::Controller();	
	}
	
	
	function index()
	{
		$this->load->view('welcome_message');
	}
	
	
	public function new_users()
	{
		for ($i = 0; $i < 3; $i++)
		{
			echo random_string('alnum', 6).'<hr />';	
		}
		exit;
	}
	
	
	public function test_make_model()
	{
		$aMapModels = array(
					'pages' => 'pages_tbl'
		);
		
		$this->load->library('model_creator');
		
		$aTables = $this->db->list_tables();

		foreach ($aTables as $sTable)
		{
			$sClassName = null;
			$sFileName = $sTable;
			
			if (in_array($sTable, $aMapModels) === true)
			{
				$sClassName = $aMapModels[$sTable];	
			}
		
			$qQueryTable = $this->db->query('SHOW TABLE STATUS FROM '.$this->db->database.' LIKE \''.$sTable.'\'');
			
			//print('<pre>');
			//print_r($qQueryTable->row(0));
			//print('</pre><hr />');
			$bIsView = ($qQueryTable->row(0)->Comment === 'VIEW') ? true : false;
		
			if ($bIsView === true)
			{
				$sFileName = 'views/'.substr($sFileName, 3);
				
				if ($sClassName === null)
				{
					$sClassName = substr($sTable, 3);
				}
			}
		
			$this->model_creator->make_model($sTable, $sClassName, $sFileName);
		}
		exit;
	}
	
	

}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */